﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace StuManager
{
    public partial class Login : Form
    {
        public Login()
        {
            InitializeComponent();
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            String username = txtUserName.Text;
            String password = txtPassword.Text;

            using (Context.MyContext ctx = new Context.MyContext())
            {
                Models.Student s = ctx.Students.FirstOrDefault( s => s.StuNo==username && s.Password == password);

                if (s != null)
                {
                    MessageBox.Show("登陆成功");
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("登陆失败");
                }
            }
        }
    }
}
